<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增指标信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-index-add">
            <input type="hidden" name="naSys" id="naSys">
            <div class="form-group">
                <label class="col-sm-3 control-label">系统：</label>
                <div class="col-sm-8">
                    <select name="sdSys" class="form-control m-b" th:with="type=${@baseSd.getItem('hos_sys')}" id="sdSys" onchange="sysChange()">
                        <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">指标后缀：</label>
                <div class="col-sm-8">
                    <select name="cdSuffix" id="cdSuffix" class="form-control m-b" th:with="type=${@suffixService.selectAll()}" onchange="suffixChange()">
                        <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">指标编码：</label>
                <div class="col-sm-8">
                    <div class="input-group m-b"><span class="input-group-addon" id="indexPrefix">IDX_HIS_</span>
                        <input type="text" class="form-control" name="idIndex" id="idIndex">
                        <span class="input-group-addon" id="indexSuffix"></span>
                    </div>
                    <!--<input name="idIndex" class="form-control" type="text">-->
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">指标名称：</label>
                <div class="col-sm-8">
                    <input name="na" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">口径：</label>
                <div class="col-sm-8">
                    <textarea name="instr" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">指标类型：</label>
                <div class="col-sm-8">
                    <select name="euTp" class="form-control m-b">
                        <option value=0>原子指标</option>
                        <option value=1>复合指标</option>
                        <option value=2>子指标</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单位：</label>
                <div class="col-sm-8">
                    <input name="unit" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="des" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "base/md/index"
        $("#form-index-add").validate({
            focusCleanup: true
        });
        function suffixChange() {
            $("#indexSuffix").html("_"+$("#cdSuffix").val());
        }
        function submitHandler() {
            if ($.validate.form()) {
                var naSys = $("#sdSys").find("option:checked").text();
                $("#naSys").val(naSys);
                $("#idIndex").val($("#indexPrefix").html()+$("#idIndex").val()+$("#indexSuffix").html());
                $.operate.save(prefix + "/add", $('#form-index-add').serialize());
            }
        }
        function sysChange() {
            var sdSys= $("#sdSys").val();
            $("#indexPrefix").html("IDX_"+sdSys.toUpperCase()+"_");
        }
        $(function () {
            $("#indexSuffix").html("_"+$("#cdSuffix").val());
        });
    </script>
</body>
</html>